<%--
  Created by IntelliJ IDEA.
  User: tangyunyuan
  Date: 2021/4/11
  Time: 17:39
  To change this template use File | Settings | File Templates.
--%>
<%@ page import="com.google.gson.Gson" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<script src="jsgol/jQuery.js"></script>
<head>
    <title>招聘管理</title>
</head>
<body>
<%
    if (session.getAttribute("msg") != null) {
        out.print("<script> alert('" + session.getAttribute("msg") + "'); </script>");
        session.removeAttribute("msg");
    }
%>
<%@include file="Canvas.jsp" %>
<div style="width:800px;height: 700px;border: gray solid 1px;margin:0 auto;background: beige;margin-top: 7%;">
    <%@include file="header.jsp" %>
    <div class="botton" style="width:100%;height:430px;border: red solid 1px;margin: 0px auto;position: relative;">
        <table id="tableData" border="1" style="width: 100%; text-align: center">

        </table>
        <div style="position: absolute;bottom: -50px;">
            <img src="idemge/down.jpg" alt="">
        </div>
        <div style="float: right;font-weight: bold">
            <%
                // 用户总数，用于判断分多少页
                Long userLen = (Long) session.getAttribute("userLen");
                if (userLen != null) {
                    for (int i = 0; i < userLen / 10 + 1; i++) {
                        out.print("<a href='" + request.getContextPath() + "/inlist?page=" + (i + 1) + "'>" + (i + 1) + "</a>");
                    }
                    out.print("共" + (userLen / 10 + 1) + "页");
                }
            %>
        </div>
        <a href="<%=request.getContextPath()%>/AddRecruitment.jsp" style="position: absolute;bottom: 40px;right: 15px;">添加应聘人员信息</a>
    </div>
</div>
</body>
<script type="text/javascript" src="jsgol/protect.js"></script>
<script>
    var Recruitment = JSON.parse('<%= new Gson().toJson(session.getAttribute("inlist"))%>');
    console.log(Recruitment);

    function createTable() {
        var data = $('#tableData');
        data.html(`<tr><th>编号</th><th>姓名</th><th>性别</th><th>应聘职务</th><th>学历</th><th>工作经验</th><th>操作</th></tr>`)
        for (let i = 0; i < Recruitment.length; i++) {
            data.append(`<tr>
                        <td>${Recruitment[i].C_id ? Recruitment[i].C_id : '无'}</td>
                        <td>${Recruitment[i].C_name ? Recruitment[i].C_name : '无'}</td>
                        <td>${Recruitment[i].C_sex ? Recruitment[i].C_sex : '无'}</td>
                        <td>${Recruitment[i].C_position ? Recruitment[i].C_position : '无'}</td>
                        <td>${Recruitment[i].C_education ? Recruitment[i].C_education : '无'}</td>
                        <td>${Recruitment[i].C_experience ? Recruitment[i].C_experience : '无'}</td>
                         <td><button onclick="">详细查询</button><button onclick="dele(${i})">删除</button><button onclick="">录用</button></td>
             </tr>`);

        }
    }

    function dele(index) {
        var sqe = confirm("确定要删除吗?");
        if (sqe == true) {
            location.href = 'delelist?delete=' + Recruitment[index].C_id;
        }
    }

    createTable();
    $('#navMore').html('> 招聘查询');
</script>

<style>
    .botton {
        background: url(idemge/6.png) no-repeat;
        background-size: 100% 100%;
    }
</style>

</html>
